//
//  PasswordChangeViewController.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/6/7.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "PasswordChangeViewController.h"

@interface PasswordChangeViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UIView *twoBackgroundView;
@property (strong, nonatomic) IBOutlet UITextField *oldPassword;//请输入支付密码
@property (strong, nonatomic) IBOutlet UITextField *Password;//请输入新支付密码
@property (strong, nonatomic) IBOutlet UITextField *isPassword;//确认信支付密码



@end

@implementation PasswordChangeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
}
- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    [self adaptiveViewLayout:self.twoBackgroundView];
    
    _scroview.contentSize = flexibleSize(CGSizeMake(0, 505), NO);
    
    self.oldPassword.secureTextEntry = YES;
    self.Password.secureTextEntry = YES;
    self.isPassword.secureTextEntry = YES;
}

#pragma mark - 返回
- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}
#pragma mark - 确认修改
- (IBAction)ConfirmChange:(id)sender {
    

    if ([Common dataIsNULL:_oldPassword.text]) {
        [CWHUDTips showTips:@"请输入支付密码"];
        return;
    }
    if ([Common dataIsNULL:_Password.text]) {
        [CWHUDTips showTips:@"请输入新支付密码"];
        return;
    }
    if ([Common dataIsNULL:_isPassword.text]) {
        [CWHUDTips showTips:@"请确认新支付密码"];
        return;
    }

    if ([self.Password.text isEqualToString:self.isPassword.text]) {
        [self ChangeThePassword];
    } else {
        [CWHUDTips showTips:@"两次输入密码不一致"];
    }
}


#pragma   mark =====  确认修改
- (void)ChangeThePassword {
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setObject:[Common shaEncrypt:self.oldPassword.text] forKey:@"exPwd"];
    [dic setObject:[Common shaEncrypt:self.isPassword.text] forKey:@"newPwd"];
    self.shareApi.delegate = self;
    [self.shareApi  requestOperationWithDic:dic withPath:SX_changePayPwd withHttpType:@"POST" withTag:SX_SX_changePayPwd];
}

#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if(tag == SX_SX_changePayPwd){
        if (  [[database valueForKey:@"type"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
        }else  {
            [self.navigationController popViewControllerAnimated:YES];
                [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:2];
        

        }
    }
}
-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    [self dismissWaitDialog];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
